package com.woniuxy.utils;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class JDKProxyInstance {
    public Object getObject(Object interfaceClazz){
        return Proxy.newProxyInstance(interfaceClazz.getClass().getClassLoader(), interfaceClazz.getClass().getInterfaces(),
                new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        System.out.println("日志打印，"+method.getName()+"方法进入一次!");
                        Object invoke = method.invoke(interfaceClazz, args);
                        System.out.println("日志打印，"+method.getName()+"方法执行结束！");
                        return invoke;
                    }
                });
    }
}
